//
//  PayButtonView.m
//  firstpoint
//
//  Created by 泽中 on 2017/7/24.
//  Copyright © 2017年 xzcysoft. All rights reserved.
//

#import "PayButtonView.h"

@implementation PayButtonView

- (instancetype)initWithFrame:(CGRect)frame data:(NSArray*)data VC:(UIViewController*)VC{
    if (self = [super initWithFrame:frame]) {
        _buttonArr=[NSMutableArray new];
        _scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 18, self.mj_w, self.mj_h-13)];
//                _scrollView.contentSize=CGSizeMake(1000, 0);
                _scrollView.showsVerticalScrollIndicator = FALSE;
                _scrollView.showsHorizontalScrollIndicator = FALSE;
        [self addSubview:_scrollView];
        _title=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 13)];
        _title.textColor=LRRGBColor(68, 68, 68);
        _title.font=[UIFont systemFontOfSize:13];
        [self addSubview:_title];

        _i=8;
        int button_W=(self.mj_w-80)/4;
        
        int button_WaddM=(self.mj_w-20-button_W)/3;
        for (int j=0; j<data.count; j++) {
            _button=[UIButton buttonWithType:UIButtonTypeCustom];
            _button.frame=CGRectMake(10+button_WaddM*j, 0, button_W, 25);
            _button.backgroundColor=LRRGBColor(249, 250, 251);
            [_button setTitleColor:LRRGBColor(68, 68, 68) forState:0];
            [_button setTitle:data[j][@"attributeValueName"] forState:0];
            _button.layer.borderWidth=1;
            [_button addTarget:VC action:@selector(xuanzhong:) forControlEvents:UIControlEventTouchUpInside];
            [_button setBackgroundImage:[UIImage imageNamed:@"spxqxz"] forState:UIControlStateSelected];
            _button.titleLabel.font=[UIFont systemFontOfSize:13];
            _button.layer.borderColor=LRRGBColor(231, 231, 231).CGColor;
            [_scrollView addSubview:_button];
            [_buttonArr addObject:_button];
        }
        _scrollView.contentSize=CGSizeMake(_button.mj_w+_button.mj_x+10, 0);
    }
    return self;
}

@end
